using Agron.Data.Contracts;

using System;
using System.Collections.Generic;
using System.ServiceModel;


namespace Agron.Services.Contracts
{
    /// <summary>
    /// Defines the service-contract for the <c>Scheduler Service</c> service.
    /// </summary>
    [ServiceContract(SessionMode = SessionMode.Required, CallbackContract = typeof(ISessionEvents),
       Namespace = "http://services.udlap.mx/Agron/SessionBroker.svc")]
    public interface ISessionBroker
    {
        /// <summary>
        /// Joins a user to a session.
        /// </summary>
        /// <param name="sessionId">The session unique identifier.</param>
        /// <param name="userId">The user's unique database identifier.</param>
        /// <param name="internetIPAddress">The internet IP address.</param>
        /// <param name="localIPAddress">The local IP address.</param>
        /// <returns>
        /// One of the <see cref="JoinSessionResult"/> enumeration values.
        /// </returns>
        /// <remarks>This will invoke the <see cref="ISessionEvents.UserJoined"/> procedure.</remarks>
        [OperationContract(IsOneWay = false, IsInitiating = true)]
        JoinSessionResult JoinSession(int sessionId, Guid userId, string internetIPAddress, string localIPAddress);

        /// <summary>
        /// Logs-off a user from a session.
        /// </summary>
        /// <param name="sessionId">The session unique identifier.</param>
        /// <param name="userId">The user's unique database identifier.</param>
        /// <remarks>This will invoke the <see cref="ISessionEvents.UserLeft"/> procedure.</remarks>
        [OperationContract(IsOneWay = true, IsTerminating = true)]
        void LeaveSession(int sessionId, Guid userId);

        /// <summary>
        /// Gets a <see cref="IEnumerable{SessionMember}"/> collection with the logged-on members of a specified session.
        /// </summary>
        /// <param name="sessionId">The session unique identifier.</param>
        /// <returns></returns>
        [OperationContract(IsOneWay = false)]
        IEnumerable<SessionMember> GetSessionMembers(int sessionId);
    }
}
